<script>
	let time = null
	export default {
		onLaunch: function() {
console.log('App Launch')
			this.$myRequest('/api/system/v1/basic/set').then(res => {
				uni.setStorageSync('phoneNumber', res.data.driverCustomerServiceMobile);
			})
			
			if(uni.getStorageSync("token")) return;
			this.$loginRequest()
		},
		onShow: function() {
			console.log('App Show')
			let that = this
			if (time) clearInterval(time)
			time = setInterval(() => {
				if (uni.getStorageSync("token")) getLocation()
			}, 60000)
			if (uni.getStorageSync("token")) getLocation()

			function getLocation() {
				uni.getLocation({
					type: 'wgs84',
					success: function(res) {
						let data = {
							addressLat: res.latitude,
							addressLng: res.longitude
						}
						that.$myRequest('/api/driver/mine/v1/update/location', data, 'POST')
					},
					fail(err) {
						console.log('定位出错', err)
					}
				});
			}
		},
		onHide: function() {
			console.log('App Hide')


		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	/*每个页面公共css */
</style>